home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / Z4.H < prev    next >
C/C++ Source or Header  |  1995-09-14  |  55KB  |  1,725 lines

  1. #ifndef _Z4_H_
  2. #define _Z4_H_
  3. //----------------------------------------------------------------------------
  4. //                            MODULE DESCRIPTION
  5. //
  6. //  Module:    z4.h
  7. //   Title:    ZIP+4 Engine
  8. //  Notice:    John M. Weeder
  9. //                 Copyright (c) 1993. All rights reserved.
  10. //             This module contains proprietary information and should be 
  11. //                treated as confidential.
  12. //
  13. //----------------------------------------------------------------------------
  14. //                           MAINTENANCE HISTORY
  15. //
  16. // $Workfile$
  17. // $Revision$
  18. //   $Author$
  19. //     $Date$
  20. //      $Log$
  21. //
  22. //----------------------------------------------------------------------------
  23. //                             MODULE NARRATIVE
  24. //
  25. //
  26. //    This is the main header file for the ZIP+4 engine.
  27. //
  28. //    The code in this module is mixed C and C++. All procedures used by
  29. //    the build procedure should be C only!
  30. //
  31. //    This module is portable to:
  32. //        DOS 3.X+
  33. //        MS Windows 3.X+
  34. //        OS/2 2.X+
  35. //        OS/2 2.0 PM
  36. //        SCO UNIX.
  37. //
  38. //    The following compilers are supported:
  39. //        MSC 6.0A
  40. //        MSC/C++ 7.0
  41. //        Borland C++ 3.1 for DOS
  42. //        Borland C++ 1.0 for OS/2 2.X
  43. //        SCO UNIX cc
  44. //
  45. //----------------------------------------------------------------------------
  46. #include <base.h>
  47. #if COMPILE_CPP
  48. #    include <class.hpp>
  49. #endif
  50. #include <dio.h>
  51. #include <data.h>
  52. #include <compress.h>
  53.  
  54.  
  55. //----------------------------------------------------------------------------
  56. //    These are special flags controlling the compile.
  57. //----------------------------------------------------------------------------
  58. #define USE_STATES_ONLY            (1)        // Only US states?
  59.  
  60.  
  61. //----------------------------------------------------------------------------
  62. //    Fields Sizes
  63. //----------------------------------------------------------------------------
  64.  
  65. //
  66. //    These are field length definitions. The field lengths do not include
  67. //    null terminators
  68. //
  69. #define MAX_ADDR_LINE        (50)        //    Address line length
  70. #define MAX_ADDR        (160)        //    Complete address line
  71.  
  72. #define MAX_INPUT_ADDR        (50)        // Input address line
  73. #define MAX_INPUT_CITY        (50)        // Input city
  74. #define MAX_INPUT_STATE        (2)        // Input state
  75. #define MAX_INPUT_ZIP        (15)        // Input ZIP
  76.  
  77. #define MAX_CITY        (28)        // City name
  78. #define MAX_CITY_ABBREV        (13)        // City abbreviation
  79. #define MAX_STATE        (2)        // State name
  80. #define MAX_ZIP5        (5)        // ZIP5
  81. #define MAX_ZIP5_BCD        (3)        // BCD encoded ZIP4
  82. #define MAX_ZIP4        (9)        // ZIP+4
  83. #define MAX_ZIP4_BCD        (5)        // BCD encoded ZIP+4
  84. #define MAX_ADDON        (4)        //    Addon
  85. #define MAX_ADDON_BCD        (2)        //    Addon BCD
  86.  
  87. #define MAX_SEC_NAME            (40)            //      Secondary name chgd fm 25 to 40
  88. #define MAX_PRI_NO        (10)        //    Primary number
  89. #define MAX_PRI_NAME            (28)            //      Primary name chgd fm 22 to 28
  90. #define MAX_SUFFIX        (4)        //    Suffix
  91. #define MAX_SEC_NO              (8)             //      Secondary number chgd fm 6 to 8
  92.                     // Maximum of primary or secondary range
  93. #define MAX_RANGE         MAX(MAX_PRI_NO,MAX_SEC_NO)
  94.  
  95. #define MAX_FINANCE         (6)        // Finance number
  96. #define MAX_FINANCE_BCD         (3)        // Finance number
  97. #define MAX_LAST_LINE         (6)        // Last line number
  98. #define MAX_LAST_LINE_BCD     (3)        // BCD encoded last line number
  99. #define MAX_LAST_LINE_NAME       (28)           // Last line name (chgd fm 25 to 28)
  100.  
  101. #define MAX_COUNTY_NO         (3)        // County number
  102. #define MAX_COUNTY_NO_BCD     (2)        // BCD encoded county number
  103. #define MAX_COUNTY         (25)        // County name
  104.  
  105. #define MAX_CRIS         (4)        //    Carrier route
  106.  
  107.  
  108. //
  109. //    Index key lengths
  110. //
  111. #define MAX_CS_KEY         (2)        //    CS key length
  112. #define MAX_CX_KEY         (2)        //    CX key length
  113. #define MAX_PF_KEY         (3)        //    PF key length
  114. #define MAX_Z4_KEY         (9)        //    Z4 key length
  115. #define MAX_Z5_KEY         (3)        //    Z5 key length
  116. #define MAX_ZX_KEY         (4)        //    PF key length
  117.  
  118.  
  119. //
  120. //    Other constants
  121. //
  122. #define MAX_ZIP5_CITIES         (60)        // Maximum number of cities in a ZIP5
  123. #define MAX_CITY_ZIP5         (300)        // Maximum number of ZIP5 in a city
  124. #define MAX_POF_ZIP5         (425)        // Maximum 5 digit ZIPs in a POF
  125. #define MAX_POF_CITY         (16)        // Maximum POF's in a city/state
  126. #define MAX_RECORDS         (256)        // Maximum multiple response records
  127. #define MAX_ZIP4_RECS         (256)        // Maximum number of records in a ZIP4
  128.  
  129.  
  130. //
  131. //    POF Tables
  132. //
  133. #define Z4_PF_TBL_DISCARD     "z4pfdisc.dat"
  134. #define Z4_PF_TBL_DISCARD_MAX     (2048)
  135. #define Z4_PF_TBL_SPLIT         "z4pfsplt.dat"
  136. #define Z4_PF_TBL_WORK         "z4pfwork.dat"
  137. #if OS_UNIX
  138. #define Z4_PF_TBL_SPLIT_MAX      (30000)
  139. #define Z4_PF_TBL_WORK_MAX       (30000)
  140. #else
  141. #define Z4_PF_TBL_SPLIT_MAX      (20000)    //chgd fm 10000
  142. #define Z4_PF_TBL_WORK_MAX       (20000)    //chgd fm 10000
  143. #endif
  144.  
  145.  
  146. //
  147. //    City/state compressor bit flags
  148. //
  149. #define CS_BYTE_FOLLOWS            (0x80)    // Another bit flag byte follows
  150.                                                 ///// Bit flag byte 1
  151. #define CS1_ZIP5_HI                     (0x40)  // New 5 digit hi range
  152. #define CS1_ZIP5_LO                     (0x20)  // New 5 digit low range
  153. #define CS1_CITY                        (0x10)  // New city name
  154. #define CS1_CITY_ABBREV            (0x08)    // New city abbreviaiton
  155. #define CS1_STATE                       (0x04)  // New state code
  156. #define CS1_FACILITY                    (0x02)  // New facility code
  157. #define CS1_NO_ZIP5_HI            (0x01)    // No ZIP5 hi range
  158.                                                 ///// Bit flag byte 2
  159. #define CS2_FINANCE                     (0x80)  // New finance number
  160. #define CS2_LAST_LINE            (0x40)    // New last line number
  161. #define CS2_LAST_LINE_NAME        (0x20)    // New last line name
  162. #define CS2_COUNTY_NO            (0x10)    // New county number
  163. #define CS2_COUNTY                      (0x08)  // New county name
  164. #define CS2_LL_IS_POF            (0x04)    // Last line and finance are equal
  165. #define CS2_LL_IS_CITY            (0x02)    // Last line name and city are same
  166. #define CS2_REC_TYPE                    (0x01)  // New record type
  167.  
  168.  
  169. //
  170. //    ZIP+4 compressor bit flags
  171. //
  172. #define Z4_BYTE_FOLLOWS            (0x8000)    // Another bit flag byte follows
  173.                                                 ///// Word flag  1
  174. #define Z41_UNIT_REC_TYPE        (0x4000)    // Unit or record type changed
  175. #define Z41_DIR                         (0x2000)        //      Directional code changed
  176. #define Z41_CODES                       (0x1000)        //      Odd/even codes or alt change
  177. #define Z41_PRI_LO                      (0x0800)        //      Primary lo change
  178. #define Z41_PRI_DELTA_LO        (0x0400)    //    Primary lo range delta
  179. #define Z41_PRI_HI                      (0x0200)        //      Primary hi change
  180. #define Z41_PRI_DELTA_HI        (0x0100)    //    Primary hi range delta
  181. #define Z41_SEC_LO                      (0x0080)        //      Secondary lo change
  182. #define Z41_SEC_HI                      (0x0040)        //      Secondary hi change
  183. #define Z41_PRI_NAME                    (0x0020)        //      Primary name change
  184. #define Z41_ADDON_LO                    (0x0010)        //      Addon lo change
  185. #define Z41_ADDON_HI                    (0x0008)        //      Addon hi change
  186. #define Z41_ADDON_LO_HI            (0x0004)    //    Add on hi lo range are equal
  187. #define Z41_SUFFIX1                     (0x0002)        //      Suffix change
  188. #define Z41_SUFFIX2                     (0x0001)        //      Suffix change
  189.  
  190.                                                 ///// Bit flag byte 2
  191. #define Z42_PRI_LO_HI            (0x80)    //    Primary hi lo range are equal
  192. #define Z42_SEC_LO_HI            (0x40)    //    Secondary hi lo range are equal    
  193. #define Z42_SEC_NAME                (0x20)    //    Secondary name change
  194. #define Z42_SEC_NAME_BLANK        (0x10)    //    Secondary name is blank
  195. #define Z42_ZIP5                    (0x08)    //    ZIP5 change
  196. #define Z42_CRIS                    (0x04)    //    CRIS change
  197. #define Z42_LAST_LINE            (0x02)    //    Last line change
  198. #define Z42_FINANCE                (0x01)    //    Finance number
  199.  
  200. //
  201. //    Miscellaneous constants
  202. //
  203. #define Z4_CS_WORD_CACHE    (1024)       // City/state word cache size
  204. #define Z4_Z4_WORD_CACHE    (1024)       // ZIP+4 word cache size
  205. #define MAX_PARSE_ELEM        (50+5)       // Maximum parse stack elements
  206.                                                ///// Record stack add/change/delete penalties
  207. #define Z4_REC_ADD           (1)           // Penalty for add
  208. #define Z4_REC_DEL           (2)           // Penalty for delete
  209. #define Z4_REC_CHG           (2)           // Penalty for change
  210.                                                 ///// Parse abbreviation types
  211. #define Z4_P_ALPHA            (0x0001)        // Alpha
  212. #define Z4_P_NUMERIC            (0x0002)        //    Numeric
  213. #define Z4_P_OTHER            (0x0004)        // Other (./-#%& etc...)
  214. #define Z4_P_SUFFIX            (0x0008)        // Suffix word (always alpha)
  215. #define Z4_P_DIR                (0x0010)        // Directional
  216. #define Z4_P_UNIT                (0x0020)        // Unit designator
  217. #define Z4_P_EXCEPT            (0x0040)        // Exceptional unit designator
  218. #define Z4_P_POB                (0x0080)        // Post office box words
  219. #define Z4_P_RR                (0x0100)        // Rural Route word
  220. #define Z4_P_HC                (0x0200)        // Highway contract word
  221. #define Z4_P_GD                (0x0400)        // General delivery word
  222. #define Z4_P_PM                (0x0800)        // Postmaster words
  223. #define Z4_P_ORDINAL            (0x1000)        // Ordinal words (ST/RD/TH/ND)
  224. #define Z4_P_EOW                (0x2000)        // End of word
  225. #define Z4_P_CHG                (0x4000)        // Word was abbreviated or changed
  226.                                                 ///// Parse flags for various internal functions
  227. #define Z4_P_PRINO            (0x0001)        // Primary range
  228. #define Z4_P_SECNO            (0x0000)        // Secondary range
  229. #define Z4_P_SECNO_FORCE    (0x0000)        // Force extraction even if suffix or dir
  230.                                                 ///// Tie breaker flags
  231. #define Z4_T_ZIP5                (0x8000)        // Record is out of input ZIP5
  232. #define Z4_T_RANGE            (0x4000)        // Record is out of range
  233.  
  234. //
  235. //    Flags to Z4_INQ::Start && Open
  236. //
  237. #define Z4_INQ_AB                (0x0001)
  238. #define Z4_INQ_CX                (0x0002)
  239. #define Z4_INQ_CS                (0x0004)
  240. #define Z4_INQ_ST                (0x0008)
  241. #define Z4_INQ_Z4                (0x0010)
  242. #define Z4_INQ_Z5                (0x0020)
  243. #define Z4_INQ_ZX                (0x0040)
  244. #define Z4_INQ_ALL            (0x0FFF)
  245. #define Z4_INQ_WRITE            (0x8000)
  246. #define Z4_INQ_REINIT        (0x4000)
  247.  
  248.  
  249. //
  250. //    Minimum adjust distances for name matching
  251. //
  252. #define MAX_CS_DIST            (10)            // City name distance
  253. #define MAX_PRI_DIST            (10)            // Primary name distance
  254. #define MAX_SEC_DIST            (16)            // Secondary name distance
  255.  
  256. //
  257. //    These defines are used to access the various tables used by
  258. //    the ZIP+4 engine.
  259. //
  260. #define Z4_DATA_FULL            (0)            // Full spelling
  261. #define Z4_DATA_ABBREV        (1)            // Abbreviation
  262. #define Z4_DATA_CODE             (2)            // Coded
  263. #define Z4_DATA_NOVICE        (3)            // Novice interpretation
  264. #define Z4_DATA_EXPERT        (4)            // Expert interpretation
  265.  
  266. //----------------------------------------------------------------------------
  267. //    Enumerated data types
  268. //----------------------------------------------------------------------------
  269. typedef enum _Z4_ALT                        /////    Alternate record indicator
  270.     {
  271.         Z4_ALT_B = 0,                                 // Base Name
  272.         Z4_ALT_A,                                 // Alternate name
  273.     Z4_ALT_MAX,
  274.     Z4_ALT_INVALID
  275.     } Z4_ALT;
  276.  
  277.  
  278. typedef enum _Z4_CODE                    /////    Odd/Even/Both
  279.         {
  280.         Z4_SPACE = 0,
  281.         Z4_BOTH,                                        // Both
  282.         Z4_ODD,                                             // Odd
  283.         Z4_EVEN,                                          // Even
  284.         Z4_CODE_INVALID,                                 // Invalid!
  285.     } Z4_CODE;
  286.  
  287.  
  288. typedef enum _Z4_CS_TYPE                       /////   City/state record type
  289.     {                                                
  290.         Z4_CS_TYPE_POB = 0,                                      // P
  291.         Z4_CS_TYPE_NON_UNIQUE,                                  //  blank
  292.         Z4_CS_TYPE_UNIQUE,                                        // U
  293.         Z4_CS_TYPE_MILITARY,                                    // M
  294.     Z4_CS_TYPE_MAX,
  295.     Z4_CS_TYPE_INVALID,
  296.     } Z4_CS_TYPE;
  297.  
  298.  
  299. typedef enum _Z4_DIR                        /////    Directional
  300.     {                                                
  301.     Z4_DIR_BLANK = 0,
  302.     Z4_DIR_N,                                    // North
  303.     Z4_DIR_E,                                    // East
  304.     Z4_DIR_S,                                    // South
  305.     Z4_DIR_W,                                    // West
  306.     Z4_DIR_NE,                                    // Northeast
  307.     Z4_DIR_SE,                                    // Southeast
  308.     Z4_DIR_SW,                                    // Southwest
  309.     Z4_DIR_NW,                                    // Northwest
  310.     Z4_DIR_MAX,
  311.     Z4_DIR_INVALID
  312.     } Z4_DIR;
  313.  
  314.  
  315. typedef enum _Z4_FACILITY                ///// Facility code
  316.     {
  317.     Z4_FACILITY_AIRPORT,                              // A
  318.     Z4_FACILITY_BRANCH,                               // B
  319.     Z4_FACILITY_COMMUNITY_PO,                         // C
  320.     Z4_FACILITY_AREA_DISTRBUTION,                     // D
  321.     Z4_FACILITY_SECTIONAL_CENTER,                     // E
  322.     Z4_FACILITY_DELIVERY_DISTRIBUTION,                // F
  323.     Z4_FACILITY_GENERAL_MAIL,                         // G
  324.     Z4_FACILITY_BULK_MAIL_CENTER,                     // K
  325.     Z4_FACILITY_MONEY_ORDER,                          // M
  326.         Z4_FACILITY_NON_POSTAL,                           // N
  327.     Z4_FACILITY_OTHER,                                // O
  328.     Z4_FACILITY_PO,                                   // P
  329.     Z4_FACILITY_STATION,                              // S
  330.     Z4_FACILITY_URBANIZATION,                         // U
  331.     Z4_FACILITY_MAX,
  332.     Z4_FACILITY_INVALID
  333.     } Z4_FACILITY;
  334.  
  335.  
  336. typedef enum _Z4_REC_CODE                /////    Record stack code
  337.     {
  338.     Z4_REC_BEST,                                // Best record
  339.     Z4_REC_FIRM,                                // Best firm
  340.     Z4_REC_FIRST = Z4_REC_FIRM,            // First record
  341.     Z4_REC_BLD,                                    // Best building
  342.     Z4_REC_BLD_DFT,                            // Best building default
  343.     Z4_REC_RR,                                    // Best RR
  344.     Z4_REC_RR_DFT,                                // Best RR default
  345.     Z4_REC_OTHER,                                // Best other (street/pob/postmaster)
  346.     Z4_REC_LAST = Z4_REC_OTHER,            // Last record
  347.     Z4_REC_MAX
  348.     } Z4_REC_CODE;
  349.  
  350.  
  351. typedef enum _Z4_RESULT                    /////    Result codes
  352.     {                                                
  353.     Z4_RESULT_FAILURE = 0,                    // Failed
  354.     Z4_RESULT_SUCCESS,                        // Generic success
  355.     Z4_RESULT_ABORT,                            // Aborted by user
  356.     Z4_RESULT_INV_ST,                            // Invalid state
  357.     Z4_RESULT_INV_CITY,                        // Invalid city
  358.     Z4_RESULT_INV_CSZ,                        // Invalid city/state or ZIP
  359.     Z4_RESULT_NOT_FOUND,                        // Address/ZIP4/ZIP5/CS not found
  360.     Z4_RESULT_MULTI,                            // Multiple match
  361.     Z4_RESULT_EXACT,                            // Exact match
  362.     } Z4_RESULT;
  363.  
  364.  
  365. typedef enum _Z4_RQ                        /////    Request codes
  366.     {
  367.     Z4_RQ_DFT = 0,                                // Default request
  368.     Z4_RQ_CS,                                   // City/state
  369.     Z4_RQ_Z4,                                   // Address inquiry
  370.     Z4_RQ_Z5,                                   // ZIP 5
  371.     Z4_RQ_ZX,                                   // ZIP 4
  372.     } Z4_RQ;
  373.  
  374.  
  375. typedef enum _Z4_STATE                                  ///// State code
  376.     {                                                // This table must match the array in
  377.     Z4_ST_INVALID = 0,        //  zbstname.c. 0 must be an invalid state!
  378.     Z4_ST_FIRST = 1,
  379. #if USE_STATES_ONLY==0
  380.    Z4_ST_AA = Z4_ST_FIRST,         //      Armed Forces America
  381.    Z4_ST_AE,                //    Armed Forces Europe
  382.    Z4_ST_AK,                //    Alaska
  383. #else
  384.    Z4_ST_AK = Z4_ST_FIRST,          //    Alaska
  385. #endif
  386.    Z4_ST_AL,                //    Alabama
  387. #if USE_STATES_ONLY==0
  388.    Z4_ST_AP,                 //    Armed Forces Pacific
  389. #endif
  390.    Z4_ST_AR,                //    Arkansas
  391. #if USE_STATES_ONLY==0
  392.    Z4_ST_AS,                                    //    American Somoa
  393. #endif
  394.    Z4_ST_AZ,                       //      Arizona
  395.    Z4_ST_CA,                       //      California
  396.    Z4_ST_CO,                       //      Colorado
  397.    Z4_ST_CT,                       //      Connecticut
  398.    Z4_ST_DC,                       //      District of Columbia
  399.    Z4_ST_DE,            //    Delaware
  400.    Z4_ST_FL,                       //      Florida
  401. #if USE_STATES_ONLY==0
  402.    Z4_ST_FM,                //    Federated States of Micronesia
  403. #endif
  404.    Z4_ST_GA,                //    Georgia
  405. #if USE_STATES_ONLY==0
  406.    Z4_ST_GU,                //    Guam
  407. #endif
  408.    Z4_ST_HI,                //    Hawaii
  409.    Z4_ST_IA,                //    Iowa
  410.    Z4_ST_ID,                //    Idaho
  411.    Z4_ST_IL,                //    Illinois
  412.    Z4_ST_IN,                //    Indiana
  413.    Z4_ST_KS,                //    Kansas
  414.    Z4_ST_KY,                //    Kentucky
  415.    Z4_ST_LA,                       //      Louisiana
  416.    Z4_ST_MA,                //    Massachussetts
  417.    Z4_ST_MD,                       //      Maryland
  418.    Z4_ST_ME,                //    Maine
  419. #if USE_STATES_ONLY==0
  420.    Z4_ST_MH,                //    Marshall Islands
  421. #endif
  422.    Z4_ST_MI,                //    Michigan
  423.    Z4_ST_MN,                //    Minnesota
  424.    Z4_ST_MO,                       //      Missouri
  425. #if USE_STATES_ONLY==0
  426.    Z4_ST_MP,                       //      Northern Mariana Islands
  427. #endif
  428.    Z4_ST_MS,                       //      Mississippi
  429.    Z4_ST_MT,                       //      Montana
  430.    Z4_ST_NC,                       //      North Carolina
  431.    Z4_ST_ND,                       //      North Dakota
  432.    Z4_ST_NE,                       //      Nebraska
  433.    Z4_ST_NH,                       //      New Hampshire
  434.    Z4_ST_NJ,                       //      New Jersey
  435.    Z4_ST_NM,                       //      New Mexico
  436.    Z4_ST_NV,                       //      Nevada
  437.    Z4_ST_NY,                       //      New York
  438.    Z4_ST_OH,                       //      Ohio
  439.    Z4_ST_OK,            //    Oklahoma
  440.    Z4_ST_OR,                //    Oregon
  441.    Z4_ST_PA,                //    Pennsylvania
  442. #if USE_STATES_ONLY==0
  443.    Z4_ST_PR,                //    Puerto Rico
  444.    Z4_ST_PW,                //    Palau
  445. #endif
  446.    Z4_ST_RI,                //    Rhode Island
  447.    Z4_ST_SC,                       //      South Carolina
  448.    Z4_ST_SD,            //    South Dakota
  449.    Z4_ST_TN,                                                                       //      Tennessee
  450.    Z4_ST_TX,                       //      Texas
  451.    Z4_ST_UT,                       //      Utah
  452.    Z4_ST_VA,                       //      Virginia
  453. #if USE_STATES_ONLY==0
  454.    Z4_ST_VI,                       //      Virgin Islands
  455. #endif
  456.     Z4_ST_VT,            //    Vermont
  457.    Z4_ST_WA,            //    Washington
  458.    Z4_ST_WI,                //    Wisconsin
  459.    Z4_ST_WV,                //    West Virginia
  460.    Z4_ST_WY,                //    Wyoming
  461.     Z4_ST_LAST = Z4_ST_WY,
  462.     Z4_ST_MAX,
  463.     Z4_ST_CODE_MASK    = 0x00FF,          // Two digit state codes only
  464.     Z4_ST_CODE             = 0x0100,          // Two digit state codes only
  465.     Z4_ST_SPELLED_OUT    = 0x0200,          // Fully spelled out state name
  466.     Z4_ST_ABBREV          = 0x0400,          // Abbreviated state name
  467.     Z4_ST_ALL            = (signed)0xFF00, // All state words, was FF00
  468.     } Z4_STATE;
  469.  
  470.  
  471. typedef enum _Z4_TYPE        /////    ZIP+4 record type
  472.     {
  473.         Z4_TYPE_ST = 0,         // Street              // chgd fm 10 to S
  474.         Z4_TYPE_POB,            // PO BOX              // chgd fm 14 to P
  475.         Z4_TYPE_RR,             // Rural Route         // chgd fm 18 to R
  476.         Z4_TYPE_HD,             // Highrise            // chgd fm 20 to H
  477.         Z4_TYPE_FM,             // Firm                // chgd fm 21 to F
  478.         Z4_TYPE_PM,             // Postmaster          // chgd fm 22 to M
  479.         Z4_TYPE_GD,             // General Delivery    // chgd fm 26 to G
  480.     Z4_TYPE_MAX,
  481.     Z4_TYPE_INVALID,
  482.     } Z4_TYPE;
  483.  
  484.  
  485. typedef enum _Z4_UNIT                    /////    Directional
  486.     {
  487.     Z4_UNIT_BLANK = 0,                        // Blank
  488.     Z4_UNIT_POUND,                                // Pound sign (same as blank
  489.     Z4_UNIT_APT,                                //    Apartment
  490.     Z4_UNIT_BOX,                                // Box (not postal standard!)
  491.     Z4_UNIT_BLDG,                                // Building
  492.     Z4_UNIT_DEPT,                                // Department
  493.     Z4_UNIT_FL,                                    // Floor
  494.     Z4_UNIT_HNGR,                                //    Hanger
  495.     Z4_UNIT_LOT,                                //    Lot
  496.     Z4_UNIT_PIER,                                // Peir
  497.     Z4_UNIT_RM,                                    // Room
  498.     Z4_UNIT_SLIP,                                // Slip
  499.     Z4_UNIT_STE,                                // Suite
  500.     Z4_UNIT_STOP,                                // Stop
  501.     Z4_UNIT_TRLR,                                // Trailer
  502.     Z4_UNIT_UNIT,                                // Unit
  503.                                                 ///// Exceptional unit designators
  504.     Z4_UNIT_BSMT,                                // Basement 
  505.     Z4_UNIT_EXCEPT = Z4_UNIT_BSMT,
  506.     Z4_UNIT_FRNT,                                //    Front
  507.     Z4_UNIT_LBBY,                                // Lobby
  508.     Z4_UNIT_LOWR,                                // Lower
  509.     Z4_UNIT_OFC,                                // Office
  510.     Z4_UNIT_PH,                                    // Penthouse
  511.     Z4_UNIT_REAR,                                // Read
  512.     Z4_UNIT_SIDE,                                // Side
  513.     Z4_UNIT_UPPR,                                // Upper
  514.     Z4_UNIT_MAX,
  515.     } Z4_UNIT;
  516.  
  517. typedef USHORT Z4_SUFFIX;
  518. BASETYPE(Z4_SUFFIX);
  519.  
  520.  
  521. //----------------------------------------------------------------------------
  522. //    Structures
  523. //----------------------------------------------------------------------------
  524. typedef struct _Z4_AB                    ///// Abbreviation structure
  525. {
  526.     SIZET cWord;                                // Word
  527.     SIZET cFull;                                // Spelled out word
  528.     SIZET cAbbrev;                                // Correct abbreviation
  529.     FLAG16 fs;                                    // Abbreviation flags
  530. } Z4_AB;
  531. BASETYPE(Z4_AB);
  532.  
  533.  
  534. typedef struct _Z4_CS                    ///// City/state record
  535. {
  536.     RECID recid;                                            // Record id
  537.    CHAR szFinance[MAX_FINANCE+1];               // Finance number
  538.         CHAR szZip5Hi[MAX_ZIP5+1];              // ZIP5 high range
  539.         CHAR szZip5Lo[MAX_ZIP5+1];              // ZIP5 low range
  540.    CHAR szCity[MAX_CITY+1];                     //     City name
  541.    CHAR szCityAbbrev[MAX_CITY_ABBREV+1];       //      City abbreviation
  542.    CHAR szLastLine[MAX_LAST_LINE+1];            //      Last line number
  543.    CHAR szLastLineName[MAX_LAST_LINE_NAME+1];    // Last line name
  544.    CHAR szCountyNo[MAX_COUNTY_NO+1];             //    County number
  545.    CHAR szCounty[MAX_COUNTY+1];                   //     County name
  546.         Z4_FACILITY facility;                   //     Facility code
  547.         Z4_CS_TYPE rectype;                      //     Record type
  548.         Z4_STATE state;                       // State code
  549. } Z4_CS;
  550. BASETYPE(Z4_CS);
  551.  
  552.  
  553. typedef struct _Z4_CS_BLK                ///// City/state expander data structure
  554. {
  555.     PVOID pcache;                                // Word cache data
  556.     Z4_CS cs;                                    // Current record
  557.     PBYTE pb;                                    // Pointer to buffer
  558.     SIZET cb;                                    // Size of buffer
  559.     SIZET cbNext;                                // Next byte to decode
  560. } Z4_CS_BLK;
  561. BASETYPE(Z4_CS_BLK);
  562.  
  563.  
  564. typedef struct _Z4_CX                    ///// City cross reference record
  565. {
  566.     RECID recid;                // Record id
  567.     Z4_STATE state;                // State code
  568.     CHAR szCity[MAX_CITY+1];        // City name
  569.     CHAR szPO[MAX_CITY+1];            // Post office name if facility code '9'
  570.     SIZET cFinance;                // Number of finance # in cs
  571.     BYTE abFinance[MAX_POF_CITY][MAX_FINANCE_BCD];    // Finance
  572.     SIZET cZip5;                // List of 5 digit ZIPs
  573.     BYTE abZip5[MAX_CITY_ZIP5][MAX_ZIP5_BCD];
  574. } Z4_CX;
  575. BASETYPE(Z4_CX);
  576.  
  577.  
  578. typedef struct _Z4_CX_BLK         // City cross reference expander data structure
  579. {
  580.         Z4_CX cx;                 // Current city/state record
  581.         PBYTE pb;                 // Pointer to buffer
  582.         SIZET cb;                 // Size of buffer
  583.         SIZET cbNext;            // Next byte to decode
  584. } Z4_CX_BLK;
  585. BASETYPE(Z4_CX_BLK);
  586.  
  587.  
  588. typedef struct _Z4_NO                    ///// Range comparison element
  589. {
  590.     SIZET cNo;                                    // Number of components
  591.     CHAR szNo[MAX_RANGE][MAX_RANGE+1];    // Components
  592.     BOOL afDash[MAX_RANGE];                    // Dash or period separator after range?
  593.     BOOL afAlpha[MAX_RANGE];                // Range is alpha?
  594.     SIZET cFract;                                // Fraction value 
  595.     Z4_CODE code;                                // Range code
  596. } Z4_NO;
  597. BASETYPE(Z4_NO);
  598.  
  599.  
  600. typedef struct _Z4_PARSE_ELEM            ///// Parse stack element
  601. {
  602.     SIZET cLen;                                    // Length of word
  603.     SIZET cWord;                                // Offset of word (may be abbreviated)
  604.     SIZET cFull;                                // Offset of spelled out word
  605.     FLAG16 fs;                                    // Flags
  606. } Z4_PARSE_ELEM;
  607. BASETYPE(Z4_PARSE_ELEM);
  608.  
  609.  
  610. typedef struct _Z4_PF                    ///// POF record
  611. {
  612.     RECID recid;                                // Record id
  613.     CHAR szFinance[MAX_FINANCE+1];        // Finance
  614.     SIZET cZip5;                                // List of 5 digit ZIP codes
  615.     BYTE abZip5[MAX_POF_ZIP5][MAX_ZIP5_BCD];
  616. } Z4_PF;
  617. BASETYPE(Z4_PF);
  618.  
  619.  
  620. typedef struct _Z4_PF_BLK                ///// POF expander data structure
  621. {
  622.     Z4_PF pf;                                    // Current record
  623.     PBYTE pb;                                    // Pointer to buffer
  624.     SIZET cb;                                    // Size of buffer
  625.     SIZET cbNext;                                // Next byte to decode
  626. } Z4_PF_BLK;
  627. BASETYPE(Z4_PF_BLK);
  628.  
  629.  
  630. typedef struct _Z4_PF_TBL                ///// POF table
  631. {
  632.     LONG lMax;                                    // Maximum size of table
  633.     LONG lSize;                                    // Number of POF's in table
  634.     BYTE abPof[1][MAX_FINANCE_BCD];        // List of POF's
  635. } Z4_PF_TBL;
  636. BASETYPE(Z4_PF_TBL);
  637.  
  638.  
  639. typedef struct _Z4_SD                    ///// State detail
  640. {
  641.     USHORT usCities;                            // Number of cities
  642.     USHORT usZips;                                // Number of unqiue ZIP 5's
  643.     USHORT usCounties;                        // Number of counties
  644.     USHORT cbCounties;                        // Size of county data
  645. } Z4_SD;
  646. BASETYPE(Z4_SD);
  647.  
  648.  
  649. typedef struct _Z4_SF                    ///// Suffix table
  650. {
  651.     SIZET cAbbrev;                                // Abbreviated suffix
  652.     SIZET cFull;                                // Spelled out suffix 
  653. } Z4_SF;
  654. BASETYPE(Z4_SF);
  655.  
  656.  
  657. typedef struct _Z4_ST_TABLE            ///// State name table entry
  658. {
  659.     PCSZ pcsz;                                    // State name
  660.     Z4_STATE code;                                                          // State code and flags
  661. } Z4_ST_TABLE;
  662. BASETYPE(Z4_ST_TABLE);
  663.  
  664.  
  665. typedef struct _Z4_Z4                    ///// ZIP+4 record
  666. {
  667.     RECID recid;                                // Record id
  668.     CHAR szFinance[MAX_FINANCE+1];        // Finance number
  669.     CHAR szZip5[MAX_ZIP5+1];                // ZIP5 
  670.    CHAR szLastLine[MAX_LAST_LINE+1];    //    Last line number
  671.     CHAR szCris[MAX_CRIS+1];                // Carrier route
  672.     CHAR szPriName[MAX_PRI_NAME+1];        // Primary name
  673.     CHAR szPriLo[MAX_PRI_NO+1];            // Primary range low
  674.     CHAR szPriHi[MAX_PRI_NO+1];            // Primary range high
  675.     CHAR szSecName[MAX_SEC_NAME+1];        // Secondary name
  676.     CHAR szSecHi[MAX_SEC_NO+1];            // Secondary range high
  677.     CHAR szSecLo[MAX_SEC_NO+1];            // Secondary range low
  678.     CHAR szAddonHi[MAX_ADDON+1];            // Secondary range high
  679.     CHAR szAddonLo[MAX_ADDON+1];            // Addon range high
  680.     Z4_SUFFIX suffix1;                        // Suffix 1 (actual)
  681.     Z4_SUFFIX suffix2;                        // Suffix 2 (from primary name)
  682.     Z4_CODE seccode;                            // Secondary odd/even/both code
  683.     Z4_CODE pricode;                            // Primary odd/even/both code
  684.     Z4_TYPE rectype;                            //    Record type
  685.     Z4_DIR predir;                                // Pre direction
  686.     Z4_DIR postdir;                            // Post direction
  687.     Z4_UNIT unit;                                // Unit designator
  688.     Z4_ALT alt;                                    // Alternate record indicator
  689.     BOOL fOrdinal;                                // Ordinal pri name (ex: 10TH, 1ST)
  690.     BOOL fNumeric;                                // Primary name is all numeric
  691. } Z4_Z4;
  692. BASETYPE(Z4_Z4);
  693.  
  694.  
  695. typedef struct _Z4_Z4_BLK                ///// ZIP+4 expander data structure
  696. {
  697.     PVOID pcache;                                // Word cache data
  698.     Z4_Z4 z4;                                    // Current record
  699.     PBYTE pb;                                    // Pointer to buffer
  700.     SIZET cb;                                    // Size of buffer
  701.     SIZET cbNext;                                // Next byte to decode
  702. } Z4_Z4_BLK;
  703. BASETYPE(Z4_Z4_BLK);
  704.  
  705.  
  706. typedef struct _Z4_REC                    /////    ZIP+4 stack record
  707. {
  708.     SIZET cCount;                                //    # records of this type
  709.     Z4_Z4 z4;
  710.     SHORT sPriName;                            // Primary name weight
  711.     SHORT sSecName;                            // Secondary name weight
  712.     SIZET cACD;                                    // Add/change/delete penalty
  713.     FLAG16 fsTie;                                // Tie breakers
  714. } Z4_REC;
  715. BASETYPE(Z4_REC);
  716.  
  717.  
  718. typedef struct _Z4_Z5                    ///// ZIP5 record
  719. {
  720.     RECID recid;                                // Record id
  721.     CHAR szZip5[MAX_ZIP5+1];                // ZIP5
  722.    CHAR szFinance[MAX_FINANCE+1];        // Finance number
  723.     SIZET cCities;                                // Number of city names
  724.     RECID arecid[MAX_ZIP5_CITIES];        // Record id's of city names
  725. } Z4_Z5;
  726. BASETYPE(Z4_Z5);
  727.  
  728. typedef struct _Z4_Z5_BLK                ///// ZIP5 expander data structure
  729. {
  730.     RECID recid;                                // Record id
  731.     Z4_Z5 z5;                                    // ZIP 5 record
  732.     PBYTE pb;                                    // Pointer to buffer
  733.     SIZET cb;                                    // Size of buffer
  734.     SIZET cbNext;                                // Next byte to decode
  735. } Z4_Z5_BLK;
  736. BASETYPE(Z4_Z5_BLK);
  737.  
  738.  
  739. typedef struct _Z4_ZX                    ///// ZIP4 cross reference record
  740. {
  741.     RECID recid;                                // Record id
  742.     CHAR szZip5[MAX_ZIP5+1];                // ZIP4
  743.     CHAR szAddonLo[MAX_ADDON+1];            // Low addon range
  744.     CHAR szAddonHi[MAX_ADDON+1];            // Hi addon range
  745.     SIZET cRecords;                            // Number of records (- 1)
  746.     RECID arecid[MAX_ZIP4_RECS];            // Record id of zip+4
  747. } Z4_ZX;
  748. BASETYPE(Z4_ZX);
  749.  
  750. typedef struct _Z4_ZX_BLK                ///// ZIP4 expander data structure
  751. {
  752.     RECID recid;                                // Record id
  753.     Z4_ZX zx;                                    // ZX record
  754.     ULONG ulZip4;                                // ZIP4 as long int
  755.     PBYTE pb;                                    // Pointer to buffer
  756.     SIZET cb;                                    // Size of buffer
  757.     SIZET cbNext;                                // Next byte to decode
  758. } Z4_ZX_BLK;
  759. BASETYPE(Z4_ZX_BLK);
  760.  
  761.  
  762. //----------------------------------------------------------------------------
  763. //    Globals
  764. //    The variables are used by the compressors and expanders so they are
  765. //    external
  766. //----------------------------------------------------------------------------
  767.  
  768. #if COMPILE_CPP     //added to compile under MSVC
  769. extern "C"
  770. {
  771.  extern CHAR _FAR_ __chWordTable[];              // Word table
  772.  extern Z4_AB _FAR_ __abbrevTable[];             // Abbreviation table
  773.  }
  774. #else 
  775.     extern CHAR _FAR_ __chWordTable[];              // Word table
  776.     extern Z4_AB _FAR_ __abbrevTable[];             // Abbreviation table
  777. #endif
  778.  
  779. extern Z4_SF _FAR_ __suffixTable[];             // Suffix table
  780. extern SIZET __cSuffixTable;
  781.  
  782. #if COMPILE_CPP
  783. extern "C"
  784.      extern SIZET __cAbbrevTable;
  785. #else 
  786.     extern SIZET __cAbbrevTable;
  787. #endif   
  788.  
  789. #define Z4_WORD(x)                      (__chWordTable + (x))
  790.  
  791. //----------------------------------------------------------------------------
  792. //    Prototypes
  793. //----------------------------------------------------------------------------
  794. #if COMPILE_CPP
  795. extern "C"
  796.     {
  797. #endif
  798.  
  799. //
  800. //    z4clean.c
  801. //
  802. PSZ FN_E Z4Clean(PSZ);
  803.  
  804.  
  805. //
  806. //    z4cscp.c
  807. //
  808. SHORT FN_E Z4CSCompress(PDATACOMP);
  809.  
  810. //
  811. //    z4csex.c
  812. //
  813. BOOL FN_E Z4CSExpand(PZ4_CS_BLK, PZ4_CS);
  814. BOOL FN_E Z4CSExpandInitialize(PZ4_CS_BLK);
  815. BOOL FN_E Z4CSExpandReset(PZ4_CS_BLK, PBYTE, SIZET);
  816. BOOL FN_E Z4CSExpandTerminate(PZ4_CS_BLK);
  817.  
  818.  
  819. //
  820. //    z4cskey.c
  821. //
  822. VOID FN_E Z4CSKey(PBYTE, Z4_STATE, PCSZ);
  823.  
  824.  
  825. //
  826. //    z4csndx.c
  827. //
  828. BOOL FN_E Z4CSIndex(PDI_INDEX);
  829.  
  830.  
  831. //
  832. //    z4cxcp.c
  833. //
  834. SHORT FN_E Z4CXCompress(PDATACOMP);
  835.  
  836.  
  837. //
  838. //    z4cxex.c
  839. //
  840. BOOL FN_E Z4CXExpand(PZ4_CX_BLK, PZ4_CX);
  841. BOOL FN_E Z4CXExpandInitialize(PZ4_CX_BLK);
  842. BOOL FN_E Z4CXExpandReset(PZ4_CX_BLK, PBYTE, SIZET);
  843. BOOL FN_E Z4CXExpandTerminate(PZ4_CX_BLK);
  844.  
  845.  
  846. //
  847. //    z4cxkey.c
  848. //
  849. VOID FN_E Z4CXKey(PBYTE pb, Z4_STATE state, PCSZ pcszCity);
  850.  
  851. //
  852. //    z4cxndx.c
  853. //
  854. BOOL FN_E Z4CXIndex(PDI_INDEX);
  855.  
  856.  
  857. //
  858. //    z4data.c
  859. //
  860. PCSZ FN_E Z4State(Z4_STATE, SIZET);
  861. Z4_STATE FN_E Z4FindState(PCSZ);
  862. PCSZ FN_E Z4CSRecordType(Z4_CS_TYPE, SIZET);
  863. Z4_CS_TYPE FN_E Z4FindCSRecordType(PCSZ);
  864. PCSZ FN_E Z4Facility(Z4_FACILITY, SIZET);
  865. Z4_FACILITY FN_E Z4FindFacility(PCSZ);
  866. PCSZ FN_E Z4Z4RecordType(Z4_TYPE, SIZET);
  867. Z4_TYPE FN_E Z4FindZ4RecordType(PCSZ);
  868. PCSZ FN_E Z4Directional(Z4_DIR, SIZET);
  869. Z4_DIR FN_E Z4FindDirectional(PCSZ);
  870. PCSZ FN_E Z4Unit(Z4_UNIT, SIZET);
  871. Z4_UNIT FN_E Z4FindUnit(PCSZ);
  872. PCSZ FN_E Z4Code(Z4_CODE, SIZET);
  873. Z4_CODE FN_E Z4FindCode(PCSZ);
  874. PCSZ FN_E Z4Alt(Z4_ALT, SIZET);
  875. Z4_ALT FN_E Z4FindAlt(PCSZ);
  876.  
  877.  
  878. //    z4pfcp.c
  879. //
  880. SHORT FN_E Z4PFCompress(PDATACOMP);
  881.  
  882.  
  883. //
  884. //    z4pfex.c
  885. //
  886. BOOL FN_E Z4PFExpand(PZ4_PF_BLK, PZ4_PF);
  887. BOOL FN_E Z4PFExpandInitialize(PZ4_PF_BLK);
  888. BOOL FN_E Z4PFExpandReset(PZ4_PF_BLK, PBYTE, SIZET);
  889. BOOL FN_E Z4PFExpandTerminate(PZ4_PF_BLK);
  890.  
  891.  
  892. //
  893. //    z4pfkey.c
  894. //
  895. VOID FN_E Z4PFKey(PBYTE, PCSZ);
  896.  
  897.  
  898. //
  899. //    z4pfndx.c
  900. //
  901. BOOL FN_E Z4PFIndex(PDI_INDEX);
  902.  
  903.  
  904. //
  905. //    z4pof.c
  906. //
  907. BOOL FN_E Z4PofAdd(PZ4_PF_TBL, PCSZ);
  908. VOID FN_E Z4PofClear(PZ4_PF_TBL);
  909. VOID FN_E Z4PofCopy(PZ4_PF_TBL, PZ4_PF_TBL, LONG);
  910. BOOL FN_E Z4PofCreate(PZ4_PF_TBL _FAR_ *, LONG);
  911. VOID FN_E Z4PofDelete(PZ4_PF_TBL, LONG);
  912. VOID FN_E Z4PofDestroy(PZ4_PF_TBL);
  913. LONG FN_E Z4PofFind(PZ4_PF_TBL, PCSZ);
  914. BOOL FN_E Z4PofRead(PZ4_PF_TBL, PCSZ);
  915. VOID FN_E Z4PofShow(PZ4_PF_TBL);
  916. BOOL FN_E Z4PofWrite(PZ4_PF_TBL, PCSZ);
  917.  
  918.  
  919. //
  920. //    z4sffile.c
  921. //
  922. PCSZ FN_E Z4SuffixAbbrev(Z4_SUFFIX);
  923. BOOL FN_E Z4SuffixFindAbbrev(PCSZ, PZ4_SUFFIX);
  924. BOOL FN_E Z4SuffixFindFull(PCSZ, PZ4_SUFFIX);
  925. PCSZ FN_E Z4SuffixFull(Z4_SUFFIX);
  926.  
  927.  
  928. //
  929. //    z4z4cp.c
  930. //
  931. SHORT FN_E Z4Z4Compress(PDATACOMP);
  932. PSZ FN_E Z4Z4CompressPriName(PSZ, PSZ, PZ4_SUFFIX, PBOOL);
  933. PSZ FN_E Z4Z4CompressRange(PSZ psz);
  934.  
  935.  
  936. //
  937. //    z4z4ex.c
  938. //
  939. BOOL FN_E Z4Z4Expand(PZ4_Z4_BLK, PZ4_Z4);
  940. BOOL FN_E Z4Z4ExpandInitialize(PZ4_Z4_BLK);
  941. BOOL FN_E Z4Z4ExpandReset(PZ4_Z4_BLK, PBYTE, SIZET);
  942. BOOL FN_E Z4Z4ExpandTerminate(PZ4_Z4_BLK);
  943.  
  944. //
  945. //    z4z4key.c
  946. //
  947. VOID FN_E Z4Z4Key(PBYTE, PCSZ, PCSZ, PCSZ);
  948.  
  949.  
  950. //
  951. //    z4z4ndx.c
  952. //
  953. BOOL FN_E Z4Z4Index(PDI_INDEX);
  954.  
  955.  
  956. //
  957. //    z4z4cnt.c
  958. //
  959. BOOL FN_E Z4Z5CountRead(PLONG, SIZET);
  960. BOOL FN_E Z4Z5CountWrite(PLONG, SIZET);
  961.  
  962.  
  963. //
  964. //    z4z5cp.c
  965. //
  966. SHORT FN_E Z4Z5Compress(PDATACOMP pdatacomp);
  967.  
  968.  
  969. //
  970. //    z4z5ex.c
  971. //
  972. BOOL FN_E Z4Z5Expand(PZ4_Z5_BLK, PZ4_Z5);
  973. BOOL FN_E Z4Z5ExpandInitialize(PZ4_Z5_BLK);
  974. BOOL FN_E Z4Z5ExpandReset(PZ4_Z5_BLK, PBYTE, SIZET);
  975. BOOL FN_E Z4Z5ExpandTerminate(PZ4_Z5_BLK);
  976.  
  977.  
  978. //
  979. //    z4z5key.c
  980. //
  981. VOID FN_E Z4Z5Key(PBYTE, PCSZ);
  982.  
  983.  
  984. //
  985. //    z4z5ndx.c
  986. //
  987. BOOL FN_E Z4Z5Index(PDI_INDEX);
  988.  
  989.  
  990. //
  991. //    z4zxcp.c
  992. //
  993. SHORT FN_E Z4ZXCompress(PDATACOMP);
  994.  
  995.  
  996. //
  997. //    z4zxex.c
  998. //
  999. BOOL FN_E Z4ZXExpand(PZ4_ZX_BLK, PZ4_ZX);
  1000. BOOL FN_E Z4ZXExpandInitialize(PZ4_ZX_BLK);
  1001. BOOL FN_E Z4ZXExpandReset(PZ4_ZX_BLK, PBYTE, SIZET);
  1002. BOOL FN_E Z4ZXExpandTerminate(PZ4_ZX_BLK);
  1003.  
  1004.  
  1005. //
  1006. //    z4zxkey.c
  1007. //
  1008. VOID FN_E Z4ZXKey(PBYTE, PCSZ);
  1009.  
  1010.  
  1011. //
  1012. //    z4zxndx.c
  1013. //
  1014. BOOL FN_E Z4ZXIndex(PDI_INDEX);
  1015.  
  1016. #if COMPILE_CPP
  1017.     }
  1018. #endif
  1019.  
  1020.  
  1021. //----------------------------------------------------------------------------
  1022. //    C++ Code
  1023. //----------------------------------------------------------------------------
  1024. #if COMPILE_CPP
  1025.  
  1026. //----------------------------------------------------------------------------
  1027. //    Class definitions
  1028. //----------------------------------------------------------------------------
  1029. CLASSDEF(Z4_AB_FILE);
  1030. CLASSDEF(Z4_CS_FILE);
  1031. CLASSDEF(Z4_CX_FILE);
  1032. CLASSDEF(Z4_SD_FILE);
  1033. CLASSDEF(Z4_ST_FILE);
  1034. CLASSDEF(Z4_Z4_FILE);
  1035. CLASSDEF(Z4_Z5_FILE);
  1036. CLASSDEF(Z4_ZX_FILE);
  1037.  
  1038. CLASSDEF(Z4_INQ);
  1039. CLASSDEF(Z4_MATCH);
  1040. CLASSDEF(Z4_PARSE);
  1041. CLASSDEF(Z4_RANGE);
  1042. CLASSDEF(Z4_STANDARDIZE);
  1043. CLASSDEF(Z4_VAL_CSZ);
  1044.  
  1045.  
  1046. //----------------------------------------------------------------------------
  1047. //    Typedefs
  1048. //----------------------------------------------------------------------------
  1049. typedef BOOL (FN_E *PFNZIP4)(SHORT = 0);        // ZIP+4 callback function
  1050.  
  1051.  
  1052. //----------------------------------------------------------------------------
  1053. //    Abbreviation file
  1054. //----------------------------------------------------------------------------
  1055. #define Z4_AB_FILE_PARENT CL_OBJECT
  1056. class CLASSTYPE Z4_AB_FILE : public Z4_AB_FILE_PARENT
  1057. {
  1058.     SIZET cCurrent;                            // Current entry
  1059.  
  1060. public:
  1061.     FN_M Z4_AB_FILE();
  1062.     virtual FN_M ~Z4_AB_FILE() {}
  1063.  
  1064.     PCSZ FN_M Abbreviation() const;
  1065.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1066.     FLAG16 FN_M Flags() const;
  1067.     BOOL FN_M Find(PCSZ);
  1068.     BOOL FN_M First();
  1069.     PCSZ FN_M Full() const;
  1070.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1071.     BOOL FN_M Next();
  1072.     BOOL FN_M Open();
  1073.     PCSZ FN_M Word() const;
  1074.  
  1075. private:
  1076.     static int __ab_find__(const void *, const void *);
  1077. };
  1078.  
  1079.  
  1080. //----------------------------------------------------------------------------
  1081. //    Class Z4_CS_FILE
  1082. //----------------------------------------------------------------------------
  1083. #define Z4_CS_FILE_PARENT CL_OBJECT
  1084. class CLASSTYPE Z4_CS_FILE : public Z4_CS_FILE_PARENT
  1085. {
  1086. static PCSZ pcszLogical;                    // Logical file name
  1087.  
  1088.     HLF hlf;                                        // Logical file handle
  1089.     HLF hlfRecNo;                                // Record number index handle
  1090.     LONG lRecs;                                    // Number of records in file
  1091.     LONG lBlocks;                                // Number of blocks in file
  1092.     LONG lBlock;                                // Current block
  1093.     USHORT usBlockSize;                        // Block size
  1094.     BOOL fBlock;                                // Block is pending in expander
  1095.     BOOL fOffset;                                // Block has started expanding
  1096.     USHORT usOffset;                            // Current record in current block
  1097.     Z4_CS_BLK z4_cs_blk;                        // Expander data
  1098.     PBYTE pb;                                    // Data for current block
  1099.  
  1100. public:
  1101.     FN_M Z4_CS_FILE();
  1102.     FN_M Z4_CS_FILE(RCZ4_CS_FILE);
  1103.     virtual FN_M ~Z4_CS_FILE();
  1104.  
  1105.     BOOL FN_M Best(RZ4_CS, RZ4_Z5, PCSZ = NULL);
  1106.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1107.     BOOL FN_M Find(RZ4_CS, Z4_STATE, PCSZ = NULL);
  1108.     BOOL FN_M First(RZ4_CS, Z4_STATE, PCSZ = NULL);
  1109.     BOOL FN_M First(RZ4_CS, LONG = 0);
  1110.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1111.     virtual BOOL FN_M IsError() const;
  1112.     virtual BOOL FN_M IsValid() const;
  1113.     BOOL FN_M Next(RZ4_CS);
  1114.     BOOL FN_M Open();
  1115.     RCZ4_CS_FILE FN_M operator=(RCZ4_CS_FILE);
  1116.     BOOL FN_M Record(RZ4_CS, LONG = -1);
  1117.     BOOL FN_M Record(RZ4_CS, RECID);
  1118.     LONG FN_M RecordNo();
  1119.     LONG FN_M Records() const
  1120.         {
  1121.         return lRecs;
  1122.         }
  1123. };
  1124.  
  1125.  
  1126. //----------------------------------------------------------------------------
  1127. //    Class Z4_CX_FILE
  1128. //----------------------------------------------------------------------------
  1129. #define Z4_CX_FILE_PARENT CL_OBJECT
  1130. class CLASSTYPE Z4_CX_FILE : public Z4_CX_FILE_PARENT
  1131. {
  1132. static PCSZ pcszLogical;                    // Logical file name
  1133.  
  1134.     HLF hlf;                                        // Logical file handle
  1135.     HLF hlfRecNo;                                // Record number index handle
  1136.     LONG lRecs;                                    // Number of records in file
  1137.     LONG lBlocks;                                // Number of blocks in file
  1138.     LONG lBlock;                                // Current block
  1139.     USHORT usBlockSize;                        // Block size
  1140.     BOOL fBlock;                                // Block is pending in expander
  1141.     BOOL fOffset;                                // Block has started expanding
  1142.     USHORT usOffset;                            // Current record in current block
  1143.     Z4_CX_BLK z4_cx_blk;                        // Expander data
  1144.     PBYTE pb;                                    // Data for current block
  1145.  
  1146. public:
  1147.     FN_M Z4_CX_FILE();
  1148.     FN_M Z4_CX_FILE(RCZ4_CX_FILE);
  1149.     virtual FN_M ~Z4_CX_FILE();
  1150.  
  1151.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1152.     BOOL FN_M Find(RZ4_CX, Z4_STATE, PCSZ = NULL);
  1153.     BOOL FN_M First(RZ4_CX, Z4_STATE, PCSZ = NULL);
  1154.     BOOL FN_M First(RZ4_CX, LONG = 0);
  1155.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1156.     virtual BOOL FN_M IsError() const;
  1157.     virtual BOOL FN_M IsValid() const;
  1158.     BOOL FN_M Next(RZ4_CX);
  1159.     BOOL FN_M Open();
  1160.     RCZ4_CX_FILE FN_M operator=(RCZ4_CX_FILE);
  1161.     BOOL FN_M Record(RZ4_CX, LONG = -1);
  1162.     BOOL FN_M Record(RZ4_CX, RECID);
  1163.     LONG FN_M RecordNo();
  1164.     LONG FN_M Records() const
  1165.         {
  1166.         return lRecs;
  1167.         }
  1168. };
  1169.  
  1170.  
  1171. //----------------------------------------------------------------------------
  1172. //    Class Z4_SD_FILE
  1173. //----------------------------------------------------------------------------
  1174. #define Z4_SD_FILE_PARENT CL_OBJECT
  1175. class CLASSTYPE Z4_SD_FILE : public Z4_SD_FILE_PARENT
  1176. {
  1177.     BOOL fValid;                                // File valid?
  1178.     Z4_SD sd;                                    // State detail data
  1179.     PCHAR pchCounties;                        // Pointer to list of counties
  1180.  
  1181. public:
  1182.     FN_M Z4_SD_FILE(Z4_STATE = Z4_ST_INVALID);
  1183.     FN_M Z4_SD_FILE(RCZ4_SD_FILE);
  1184.     virtual FN_M ~Z4_SD_FILE();
  1185.  
  1186.     USHORT FN_M Cities() const
  1187.         {
  1188.         return sd.usCities;
  1189.         }
  1190.     USHORT FN_M Counties() const
  1191.         {
  1192.         return sd.usCounties;
  1193.         }
  1194.     PCHAR FN_M CountyNames() const
  1195.         {
  1196.         return pchCounties ? pchCounties: "";
  1197.         }
  1198.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1199.     BOOL FN_M Get(Z4_STATE);
  1200.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1201.     virtual BOOL FN_M IsValid() const;
  1202.     RCZ4_SD_FILE FN_M operator=(RCZ4_SD_FILE);
  1203.     USHORT FN_M Zips() const
  1204.         {
  1205.         return sd.usZips;
  1206.         }
  1207. };
  1208.  
  1209.  
  1210. //----------------------------------------------------------------------------
  1211. //    Z4_ST_FILE
  1212. //----------------------------------------------------------------------------
  1213. #define Z4_ST_FILE_PARENT CL_OBJECT
  1214. class CLASSTYPE Z4_ST_FILE : public Z4_ST_FILE_PARENT
  1215. {
  1216.     static Z4_ST_TABLE aiStateTable[];
  1217.  
  1218.     Z4_STATE mask;                                // Mask for state names
  1219.     SIZET cCurrent;                            // Current entry
  1220.  
  1221. public:
  1222.     FN_M Z4_ST_FILE(Z4_STATE = Z4_ST_ALL);
  1223.     virtual FN_M ~Z4_ST_FILE() {}
  1224.  
  1225.     PCSZ FN_M Abbreviation();
  1226.     static PCSZ FN_M Abbreviation(Z4_STATE);
  1227.     Z4_STATE FN_M Code() const
  1228.         {
  1229.                  // return aiStateTable[cCurrent].code & Z4_ST_CODE_MASK; //org code
  1230.                  return (Z4_STATE)(aiStateTable[cCurrent].code & Z4_ST_CODE_MASK);
  1231.         }
  1232.     SIZET FN_M Current() const
  1233.         {
  1234.         return cCurrent;
  1235.         }
  1236.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1237.     Z4_STATE FN_M Find(PCSZ);
  1238.     Z4_STATE FN_M First();
  1239.     Z4_STATE FN_M First(PCSZ);
  1240.     Z4_STATE FN_M Flags() const
  1241.         {
  1242.                 //return aiStateTable[cCurrent].code & Z4_ST_ALL; //org code
  1243.                 return (Z4_STATE)(aiStateTable[cCurrent].code & Z4_ST_ALL);
  1244.         }
  1245.     PCSZ FN_M Full();
  1246.     static PCSZ FN_M Full(Z4_STATE);
  1247.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1248.     Z4_STATE FN_M Next();
  1249.     BOOL FN_M Open();
  1250.     FN_M operator PCSZ() const
  1251.         {
  1252.         return aiStateTable[cCurrent].pcsz;
  1253.         }
  1254.     FN_M operator PSZ() const
  1255.         {
  1256.         return (PSZ)aiStateTable[cCurrent].pcsz;
  1257.         }
  1258.     PCSZ FN_M Record(LONG);
  1259.     LONG FN_M RecordNo();
  1260.     SIZET FN_M Records();
  1261.     VOID FN_M SetMask(Z4_STATE _mask = Z4_ST_ALL)
  1262.         {
  1263.         mask = _mask;
  1264.         return ;
  1265.         }
  1266. };
  1267.  
  1268.  
  1269. //----------------------------------------------------------------------------
  1270. //    Class Z4_Z4_FILE
  1271. //----------------------------------------------------------------------------
  1272. #define Z4_Z4_FILE_PARENT CL_OBJECT
  1273. class CLASSTYPE Z4_Z4_FILE : public Z4_Z4_FILE_PARENT
  1274. {
  1275. static PCSZ pcszLogical;                    // Logical file name
  1276.  
  1277.     HLF hlf;                                        // Logical file handle
  1278.     HLF hlfRecNo;                                // Record number index handle
  1279.     LONG lRecs;                                    // Number of records in file
  1280.     LONG lBlocks;                                // Number of blocks in file
  1281.     LONG lBlock;                                // Current block
  1282.     USHORT usBlockSize;                        // Block size
  1283.     BOOL fBlock;                                // Block is pending in expander
  1284.     BOOL fOffset;                                // Block has started expanding
  1285.     USHORT usOffset;                            // Current record in current block
  1286.     Z4_Z4_BLK z4_z4_blk;                        // Expander data
  1287.     PBYTE pb;                                    // Data for current block
  1288.  
  1289. public:
  1290.     FN_M Z4_Z4_FILE();
  1291.     FN_M Z4_Z4_FILE(RCZ4_Z4_FILE);
  1292.     virtual FN_M ~Z4_Z4_FILE();
  1293.  
  1294.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1295.     BOOL FN_M First(RZ4_Z4, PCSZ, PCSZ = NULL, PCSZ = NULL);
  1296.     BOOL FN_M First(RZ4_Z4, LONG = 0);
  1297.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1298.     virtual BOOL FN_M IsError() const;
  1299.     virtual BOOL FN_M IsValid() const;
  1300.     BOOL FN_M Next(RZ4_Z4);
  1301.     BOOL FN_M Open();
  1302.     RCZ4_Z4_FILE FN_M operator=(RCZ4_Z4_FILE);
  1303.     BOOL FN_M Record(RZ4_Z4, LONG = -1);
  1304.     BOOL FN_M Record(RZ4_Z4, RECID);
  1305.     LONG FN_M RecordNo();
  1306.     LONG FN_M Records() const
  1307.         {
  1308.         return lRecs;
  1309.         }
  1310. };
  1311.  
  1312.  
  1313. //----------------------------------------------------------------------------
  1314. //    Class Z4_Z5_FILE
  1315. //----------------------------------------------------------------------------
  1316. #define Z4_Z5_FILE_PARENT CL_OBJECT
  1317. class CLASSTYPE Z4_Z5_FILE : public Z4_Z5_FILE_PARENT
  1318. {
  1319. static PCSZ pcszLogical;                    // Logical file name
  1320.  
  1321.     HLF hlf;                                        // Logical file handle
  1322.     HLF hlfRecNo;                                // Record number index handle
  1323.     LONG lRecs;                                    // Number of records in file
  1324.     LONG lBlocks;                                // Number of blocks in file
  1325.     LONG lBlock;                                // Current block
  1326.     USHORT usBlockSize;                        // Block size
  1327.     BOOL fBlock;                                // Block is pending in expander
  1328.     BOOL fOffset;                                // Block has started expanding
  1329.     USHORT usOffset;                            // Current record in current block
  1330.     Z4_Z5_BLK z4_z5_blk;                        // Expander data
  1331.     PBYTE pb;                                    // Data for current block
  1332.  
  1333. public:
  1334.     FN_M Z4_Z5_FILE();
  1335.     FN_M Z4_Z5_FILE(RCZ4_Z5_FILE);
  1336.     virtual FN_M ~Z4_Z5_FILE();
  1337.  
  1338.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1339.     BOOL FN_M Find(RZ4_Z5, PCSZ);
  1340.     BOOL FN_M First(RZ4_Z5, PCSZ);
  1341.     BOOL FN_M First(RZ4_Z5, LONG = 0);
  1342.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1343.     virtual BOOL FN_M IsError() const;
  1344.     virtual BOOL FN_M IsValid() const;
  1345.     BOOL FN_M Next(RZ4_Z5);
  1346.     BOOL FN_M Open();
  1347.     RCZ4_Z5_FILE FN_M operator=(RCZ4_Z5_FILE);
  1348.     BOOL FN_M Record(RZ4_Z5, LONG = -1);
  1349.     BOOL FN_M Record(RZ4_Z5, RECID);
  1350.     LONG FN_M RecordNo();
  1351.     LONG FN_M Records() const
  1352.         {
  1353.         return lRecs;
  1354.         }
  1355. };
  1356.  
  1357.  
  1358. //----------------------------------------------------------------------------
  1359. //    Class Z4_ZX_FILE
  1360. //----------------------------------------------------------------------------
  1361. #define Z4_ZX_FILE_PARENT CL_OBJECT
  1362. class CLASSTYPE Z4_ZX_FILE : public Z4_ZX_FILE_PARENT
  1363. {
  1364. static PCSZ pcszLogical;                    // Logical file name
  1365.  
  1366.     HLF hlf;                                        // Logical file handle
  1367.     HLF hlfRecNo;                                // Record number index handle
  1368.     LONG lRecs;                                    // Number of records in file
  1369.     LONG lBlocks;                                // Number of blocks in file
  1370.     LONG lBlock;                                // Current block
  1371.     USHORT usBlockSize;                        // Block size
  1372.     BOOL fBlock;                                // Block is pending in expander
  1373.     BOOL fOffset;                                // Block has started expanding
  1374.     USHORT usOffset;                            // Current record in current block
  1375.     Z4_ZX_BLK z4_zx_blk;                        // Expander data
  1376.     PBYTE pb;                                    // Data for current block
  1377.  
  1378. public:
  1379.     FN_M Z4_ZX_FILE();
  1380.     FN_M Z4_ZX_FILE(RCZ4_ZX_FILE);
  1381.     virtual FN_M ~Z4_ZX_FILE();
  1382.  
  1383.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1384.     BOOL FN_M Find(RZ4_ZX, PCSZ);
  1385.     BOOL FN_M First(RZ4_ZX, PCSZ);
  1386.     BOOL FN_M First(RZ4_ZX, LONG = 0);
  1387.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1388.     virtual BOOL FN_M IsError() const;
  1389.     virtual BOOL FN_M IsValid() const;
  1390.     BOOL FN_M Next(RZ4_ZX);
  1391.     BOOL FN_M Open();
  1392.     RCZ4_ZX_FILE FN_M operator=(RCZ4_ZX_FILE);
  1393.     BOOL FN_M Record(RZ4_ZX, LONG = -1);
  1394.     BOOL FN_M Record(RZ4_ZX, RECID);
  1395.     LONG FN_M RecordNo();
  1396.     LONG FN_M Records() const
  1397.         {
  1398.         return lRecs;
  1399.         }
  1400. };
  1401.  
  1402.  
  1403. //----------------------------------------------------------------------------
  1404. //    Class Z4_VAL_CSZ
  1405. //----------------------------------------------------------------------------
  1406. #define Z4_VAL_CSZ_PARENT CL_OBJECT
  1407. class CLASSTYPE Z4_VAL_CSZ : public Z4_VAL_CSZ_PARENT
  1408. {
  1409.     BOOL fIsValZ5;                                // Valid ZIP5 record?
  1410.     BOOL fIsValCS;                                // Valid CS record?
  1411.  
  1412. public:
  1413.     CHAR szZip5[MAX_ZIP5+1];                                    // Input ZIP5
  1414.     CHAR szZ5Finance[MAX_FINANCE+1];                            // ZIP5 finance
  1415.     SIZET cFinance;                                                // Number of finance #'s
  1416.     CHAR aszCSFinance[MAX_POF_CITY+1][MAX_FINANCE+1];    // CS finance list
  1417.  
  1418.     FN_M Z4_VAL_CSZ();
  1419.     FN_M Z4_VAL_CSZ(RCZ4_VAL_CSZ);
  1420.     virtual FN_M ~Z4_VAL_CSZ();
  1421.  
  1422.     VOID FN_M Clear();
  1423.     BOOL FN_M CS(PCSZ, Z4_STATE);
  1424.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1425.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1426.     BOOL FN_M IsValidCS() const
  1427.         {
  1428.         return fIsValCS;
  1429.         }
  1430.     BOOL FN_M IsValidZ5() const
  1431.         {
  1432.         return fIsValZ5;
  1433.         }
  1434.     BOOL FN_M Z5(PCSZ);
  1435. };
  1436.  
  1437.  
  1438. //----------------------------------------------------------------------------
  1439. //    Class Z4_PARSE
  1440. //----------------------------------------------------------------------------
  1441. #define Z4_PARSE_PARENT CL_OBJECT
  1442. class CLASSTYPE Z4_PARSE : public Z4_PARSE_PARENT
  1443. {
  1444.     static SIZET cBuf;                                      // Amount of buffer used!
  1445.     static CHAR szBuffer[256];                              // Parse buffer size
  1446.     static SIZET cStack;                                      // Parse stack size
  1447.     static Z4_PARSE_ELEM pelem[MAX_PARSE_ELEM];        // Stack elements
  1448.  
  1449. public:
  1450.     CHAR szAddr1[MAX_ADDR_LINE+1];        // Input address line 1
  1451.     CHAR szAddr2[MAX_ADDR_LINE+1];        // Input address line 2
  1452.     CHAR szLastLine[MAX_ADDR_LINE+1];    // Input last line
  1453.  
  1454.     CHAR szPriNoReformat[MAX_RANGE+1];    // Reformatted primary number
  1455.  
  1456.     CHAR szPriNo[MAX_RANGE+1];                // Parsed primary number
  1457.     Z4_DIR predir;                                // Parsed predirection
  1458.     CHAR szPriName[MAX_PRI_NAME+1];        // Parsed primary name
  1459.     BOOL fPriNumeric;                            // Primary name is numeric
  1460.     Z4_SUFFIX suffix1;                        // Parsed suffix 1
  1461.     Z4_SUFFIX suffix2;                        // Parsed suffix 2
  1462.     Z4_DIR postdir;                            // Parsed post direction
  1463.     Z4_UNIT unit;                                // Parsed unit designator
  1464.     CHAR szSecNo[MAX_RANGE+1];                // Parsed secondary number
  1465.  
  1466.     CHAR szSecName[MAX_SEC_NAME+1];        // Parsed secondary name
  1467.  
  1468.     CHAR szCity[MAX_CITY+1];                // Parsed city
  1469.     BOOL fInvState;                            // Invalid city/state
  1470.     Z4_STATE state;                            // Parsed state
  1471.     CHAR szZip5[MAX_ZIP5+1];                // Parsed 5 digit 
  1472.     CHAR szAddon[MAX_ADDON+1];                // Parsed addon
  1473.     CHAR szZip4[MAX_ZIP4+1];                // Parsed ZIP+4
  1474.  
  1475.     FN_M Z4_PARSE();
  1476.     FN_M Z4_PARSE(RCZ4_PARSE);
  1477.     virtual FN_M ~Z4_PARSE();
  1478.  
  1479.     VOID FN_M Clear();
  1480.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1481.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1482.     BOOL FN_M LastLine(PCSZ, PCSZ = NULL, PCSZ = NULL);
  1483.     BOOL FN_M Primary(PCSZ);
  1484.     BOOL FN_M Secondary(PCSZ);
  1485.  
  1486. protected:
  1487.     VOID FN_M Abbreviate();
  1488.     SIZET FN_M AddString(PCCHAR, SIZET = 0);
  1489.     VOID FN_M AvenueX();
  1490.     VOID FN_M Break(PCSZ);
  1491.     BOOL FN_M City();
  1492.     VOID FN_M Clean();
  1493.     VOID FN_M Collapse();
  1494.     PCSZ FN_M Combine(PSZ, SIZET, SIZET = 0, SIZET = 0xFFFF, BOOL = TRUE);
  1495.     VOID FN_M Delete(SIZET, SIZET = 1);
  1496.     VOID FN_M Ordinal();
  1497.     BOOL FN_M POB();
  1498.     VOID FN_M PostDir();
  1499.     VOID FN_M PreDir();
  1500.     VOID FN_M PriName();
  1501.     VOID FN_M PriNo();
  1502.     BOOL FN_M Range(PSZ, SIZET, SIZET, FLAG16);
  1503.     BOOL FN_M RRHC();
  1504.     VOID FN_M SecNo();
  1505.     BOOL FN_M State();
  1506.     Z4_SUFFIX FN_M Suffix();
  1507.     PSZ FN_M Word(SIZET cWord)
  1508.         {
  1509.         return szBuffer + cWord;
  1510.         }
  1511.     BOOL FN_M Zip4();
  1512.  
  1513. };
  1514.  
  1515.  
  1516. //----------------------------------------------------------------------------
  1517. //    Class Z4_RANGE
  1518. //----------------------------------------------------------------------------
  1519. #define Z4_RANGE_PARENT CL_OBJECT
  1520. class CLASSTYPE Z4_RANGE : public Z4_RANGE_PARENT
  1521. {
  1522.     CHAR szNo[MAX_RANGE+1], szLo[MAX_RANGE+1], szHi[MAX_RANGE+1];
  1523.       Z4_NO no, lo, hi;
  1524.  
  1525. public:
  1526.     FN_M Z4_RANGE();
  1527.     FN_M Z4_RANGE(RCZ4_RANGE);
  1528.     virtual FN_M ~Z4_RANGE();
  1529.  
  1530.     Z4_CODE FN_M Code() const
  1531.         {
  1532.         return no.code;
  1533.         }
  1534.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1535.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1536.     BOOL FN_M Primary(PCSZ, PCSZ, PCSZ, Z4_CODE);
  1537.     BOOL FN_M Secondary(PCSZ, PCSZ, PCSZ, Z4_CODE);
  1538.  
  1539. private:
  1540.     BOOL FN_M Break(PCSZ, RZ4_NO);
  1541.     BOOL FN_M Compare();
  1542.     BOOL FN_M Exception();
  1543.     BOOL FN_M Input(PSZ, PCSZ, SIZET);
  1544.     BOOL FN_M Validate();
  1545. };
  1546.  
  1547.  
  1548. //----------------------------------------------------------------------------
  1549. //    Class Z4_MATCH
  1550. //----------------------------------------------------------------------------
  1551. #define Z4_MATCH_PARENT CL_OBJECT
  1552. class CLASSTYPE Z4_MATCH : public Z4_MATCH_PARENT
  1553. {
  1554.     Z4_RANGE range;                            // Range class
  1555.     Z4_VAL_CSZ valcsz;                        // Validate C/S/Z class
  1556.     PZ4_PARSE pparse;                            // Parse data pointer
  1557.     TIMET timetLast;
  1558.     BOOL fAbort;                                // Abort flag
  1559.  
  1560. public:
  1561.                                                 ///// Other
  1562.     PFNZIP4 pfnzip4;                            // Call back
  1563.                                                 ///// Matched records
  1564.     Z4_REC rec[Z4_REC_MAX];                    // Matched record stack
  1565.                                                 ///// Record stack
  1566.     SIZET cRecords;                            // Number of records on stack
  1567.     RECID arecid[MAX_RECORDS];                // Selected record stack ids
  1568.  
  1569.     BOOL fStackOverFlow;                        // Address stack overflow
  1570.     BOOL fBetterAvailable;                    // Better record available
  1571.     BOOL fInvZip4;                                // Invalid ZIP+4
  1572.     BOOL fInvZip5;                                // Invalid ZIP5
  1573.     BOOL fInvCity;                                // Invalid city/state
  1574.     BOOL fNoPrimary;                            // No primary number match
  1575.     BOOL fSecAvail;                            // Secondary range available
  1576.     BOOL fInvSec;                                // Invalid secondary number
  1577.  
  1578.     FN_M Z4_MATCH();
  1579.     virtual FN_M ~Z4_MATCH();
  1580.  
  1581.     VOID FN_M Clear();
  1582.     Z4_RESULT FN_M CS(RZ4_PARSE);
  1583.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1584.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1585.     Z4_RESULT FN_M Z4(RZ4_PARSE);
  1586.     Z4_RESULT FN_M Z5(RZ4_PARSE);
  1587.     Z4_RESULT FN_M ZX(RZ4_PARSE);
  1588.  
  1589. private:
  1590.     BOOL FN_M Building();
  1591.     VOID FN_M ClearRecords(BOOL = TRUE);
  1592.     VOID FN_M ClearStack();
  1593.     BOOL FN_M Compare();
  1594.     Z4_RESULT FN_M Finish();
  1595.     BOOL FN_M Firm();
  1596.     BOOL FN_M Other();
  1597.     BOOL FN_M RR();
  1598.     BOOL FN_M Select(Z4_REC_CODE);
  1599.     BOOL FN_M Search(PCSZ);
  1600. };
  1601.  
  1602.  
  1603. //----------------------------------------------------------------------------
  1604. //    Class Z4_STANDARDIZE
  1605. //----------------------------------------------------------------------------
  1606. #define Z4_STANDARDIZE_PARENT CL_OBJECT
  1607. class CLASSTYPE Z4_STANDARDIZE : public Z4_STANDARDIZE_PARENT
  1608. {
  1609.     BOOL FN_M Complete();
  1610.     BOOL FN_M LastLine(RZ4_CS, PCSZ, PCSZ = NULL);
  1611.  
  1612. public:
  1613.                                                 ///// Display address
  1614.     CHAR szAddress[MAX_ADDR+1];            // Complete address
  1615.     CHAR szAddr1[MAX_ADDR_LINE+1];        // Address line 1
  1616.     CHAR szAddr2[MAX_ADDR_LINE+1];        // Address line 2
  1617.     CHAR szLastLine[MAX_ADDR_LINE+1];    // Last line
  1618.                                                 ///// Display pieces
  1619.     CHAR szCity[MAX_CITY+1];                // City name
  1620.     Z4_STATE state;                            // State
  1621.     CHAR szZip5[MAX_ZIP5+1];                // 5 digit ZIP
  1622.     CHAR szAddon[MAX_ZIP4+1];                // Addon 
  1623.     CHAR szZip4[MAX_ZIP4+2];                // 9 digit ZIP w/ dash
  1624.                                                 ///// Flags
  1625.     BOOL fFacilityOther;                        // Facility code 9 city names in ZIP5
  1626.     BOOL fNonDeliverable;                    // Address is non-deliverable
  1627.  
  1628.     FN_M Z4_STANDARDIZE();
  1629.     virtual FN_M ~Z4_STANDARDIZE();
  1630.  
  1631.     static VOID FN_M Addr1Display(PSZ, RZ4_Z4);
  1632.     static VOID FN_M Addr2Display(PSZ, RZ4_Z4, PCSZ = NULL, PCSZ = NULL, Z4_UNIT = Z4_UNIT_BLANK);
  1633.     VOID FN_M Clear();
  1634.     BOOL FN_M CS(RZ4_CX, PCSZ);
  1635.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1636.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1637.     static VOID FN_M LastLineDisplay(PSZ, RZ4_CS, PCSZ, PCSZ = NULL);
  1638.     static VOID FN_M PriRangeDisplay(PSZ, RZ4_Z4);
  1639.     static PSZ FN_M RangeDisplay(PSZ, PCSZ);
  1640.     static VOID FN_M SecRangeDisplay(PSZ, RZ4_Z4);
  1641.     BOOL FN_M Z4(RRECID, RZ4_PARSE);
  1642.     BOOL FN_M Z5(RRECID, PCSZ);
  1643.     BOOL FN_M ZX(RRECID, PCSZ);
  1644. };
  1645.  
  1646.  
  1647. //----------------------------------------------------------------------------
  1648. //    Class Z4_INQ
  1649. //----------------------------------------------------------------------------
  1650.  
  1651.  
  1652. #define Z4_INQ_PARENT CL_OBJECT
  1653. class CLASSTYPE Z4_INQ : public Z4_INQ_PARENT
  1654. {
  1655. public:
  1656.     static BOOL fInit;
  1657.                                                 ///// Data files
  1658.     static Z4_AB_FILE ab_file;                // Abbrevation file
  1659.     static Z4_CS_FILE cs_file;                // City/state file
  1660.     static Z4_CX_FILE cx_file;                // City/state cross reference 
  1661.     static Z4_ST_FILE st_file;                // State file
  1662.     static Z4_Z4_FILE z4_file;                // ZIP+4 file
  1663.     static Z4_Z5_FILE z5_file;                // ZIP 5 file
  1664.     static Z4_ZX_FILE zx_file;                // ZIP+4 cross reference
  1665.                                                 ///// Work area
  1666.     static Z4_CS cs;                            // City/state record
  1667.     static Z4_CX cx;                            // City/state cross reference
  1668.     static Z4_Z4 z4;                            // ZIP4 record
  1669.     static Z4_Z5 z5;                            // ZIP5 record
  1670.     static Z4_ZX zx;                            // ZIP4 cross reference record
  1671.                                                 ///// Request and result codes/
  1672.     Z4_RQ request;                                // Request 
  1673.     Z4_RESULT result;                            // Result
  1674.     PFNZIP4 pfnzip4;                            // Call back
  1675.                                                 ///// Flags
  1676.     BOOL fInvZip4;                                // Invalid ZIP+4
  1677.     BOOL fInvZip5;                                // Invalid ZIP5
  1678.     BOOL fInvCity;                                // Invalid city/state
  1679.     BOOL fInvState;                                // Invalid city/state
  1680.     BOOL fZip5Changed;                        // ZIP 5 changed
  1681.     BOOL fCSChanged;                            // City/state changed
  1682.     BOOL fAddrChanged;                        // Address line changed
  1683.     BOOL fFacilityOther;                        // Facility code 9 city names in ZIP5
  1684.     BOOL fNonDeliverable;                    // Address is non-deliverable
  1685.     BOOL fBetterAvailable;                    // Better record available
  1686.     BOOL fNoPrimary;                            // No primary number match
  1687.     BOOL fSecAvail;                            // Secondary range available
  1688.     BOOL fInvSec;                                // Invalid secondary number
  1689.     BOOL fStackOverFlow;                        // Address stack overflow
  1690.                                                 ///// Input address data
  1691.     CHAR szAddr1[MAX_INPUT_ADDR+1];        // Input address line 1
  1692.     CHAR szAddr2[MAX_INPUT_ADDR+1];        // Input address line 2
  1693.     CHAR szCity[MAX_INPUT_CITY+1];        // Input city name
  1694.     CHAR szState[MAX_INPUT_STATE+1];        // Input state
  1695.     CHAR szZip[MAX_INPUT_ZIP+1];            // Input ZIP
  1696.                                                 ///// Parsed address data
  1697.     Z4_MATCH match;                            // Match class
  1698.     Z4_PARSE parse;                            // Parse class
  1699.     Z4_STANDARDIZE std;                        // Standardize class
  1700.     SIZET cSelect;                                // Selected match item.
  1701.  
  1702.     FN_M Z4_INQ();
  1703.     FN_M Z4_INQ(RCZ4_INQ);
  1704.     virtual FN_M ~Z4_INQ();
  1705.  
  1706.     VOID FN_M Clear();
  1707.     static BOOL FN_M Close();
  1708.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  1709.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  1710.     BOOL FN_M Inquiry(Z4_RQ = Z4_RQ_DFT);
  1711.     static BOOL FN_M Open(FLAG16 = Z4_INQ_ALL);
  1712.     BOOL FN_M Select(SIZET = 0);
  1713.     BOOL FN_M Set(PCSZ, PCSZ, PCSZ, PCSZ = NULL, PCSZ = NULL);
  1714.     static BOOL FN_E Start(FLAG16 = Z4_INQ_ALL);
  1715.     static BOOL FN_E Terminate();
  1716.  
  1717. protected:
  1718.     VOID FN_M Flags();
  1719. };
  1720. //----------------------------------------------------------------------------
  1721. //------------------------------- End of File --------------------------------
  1722. //----------------------------------------------------------------------------
  1723. #endif                                            // COMPILE_CPP
  1724. #endif                                            //  _Z4_H_
  1725.